 #ifndef CHATCLIENT_H
#define CHATCLIENT_H

#include <QWidget>
#include <qbluetoothserviceinfo.h>
#include <QBluetoothSocket>
#include <QtCore/QObject>
namespace Ui {
class ChatClient;
}

class ChatClient : public QWidget
{
    Q_OBJECT

public:
    explicit ChatClient(QWidget *parent = nullptr);
    ~ChatClient();
    void startClient(const QBluetoothServiceInfo &remoteService);//开启客户端
    void stopClient();//停止客户端
public slots:
    void sendMessage(const QString &message);//发送消息
    void disconnect();//主动断开连接
signals:
    /* 接收到消息信号 */
    void messageReceived(const QString &sender, const QString &message);

    /* 连接信号 */
    void connected(const QString &name);

    /* 断开连接信号 */
    void disconnected();
private slots:
    void readSocket();//从 socket 里读取消息
    void connected();//连接
private:
    QBluetoothSocket *socket;
    //socket 通信

};

#endif // CHATCLIENT_H
